/**
 * @description 生成统计列表
 * @author 李子一
 */

import Mock from 'mockjs'
import getComponentList from './getComponentList.js'

const { Random } = Mock

export default function getStatList(len = 10) {
  const componentList = getComponentList()

  const res = []

  for (let i = 0; i < len; i++) {
    // 一个用户的答卷
    const stat = {
      _id: Random.id(),
    }

    // 增加各个组件的 id value
    componentList.forEach(({ fe_id, type, props }) => {
      switch (type) {
        case 'questionInput':
          stat[fe_id] = Random.ctitle()
          break
        case 'questionTextarea':
          stat[fe_id] = Random.ctitle()
          break
        case 'questionRadio':
          stat[fe_id] = props.options[0].text
          break
        case 'questionCheckbox':
          stat[fe_id] = `${props.list[0].text}, ${props.list[1].text}`
          break
      }
    })
    res.push(stat)
  }

  return res
}
